package org.pvs.superpalitos.sp_lite.gui;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.SwingConstants;
import javax.swing.JButton;

import org.pvs.superpalitos.sp_lite.SuperPalitos;

import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import java.awt.GridLayout;

public class PartidaPanel extends JPanel {
	private JLabel marcadorLabel;
	private JPanel finPanel;
	private JLabel jLabel1;
	public PartidaPanel() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 1.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		marcadorLabel = new JLabel("New label");
		marcadorLabel.setHorizontalAlignment(SwingConstants.RIGHT);
		GridBagConstraints gbc_marcadorLabel = new GridBagConstraints();
		gbc_marcadorLabel.anchor = GridBagConstraints.EAST;
		gbc_marcadorLabel.insets = new Insets(4, 0, 5, 8);
		gbc_marcadorLabel.gridx = 0;
		gbc_marcadorLabel.gridy = 0;
		add(marcadorLabel, gbc_marcadorLabel);
		
		jLabel1 = new JLabel("New label");
		GridBagConstraints gbc_jLabel1 = new GridBagConstraints();
		gbc_jLabel1.anchor = GridBagConstraints.EAST;
		gbc_jLabel1.insets = new Insets(8, 0, 0, 8);
		gbc_jLabel1.gridx = 0;
		gbc_jLabel1.gridy = 2;
		add(jLabel1, gbc_jLabel1);
		
		finPanel = new JPanel();
		finPanel.setOpaque(false);
		GridBagConstraints gbc_finPanel = new GridBagConstraints();
		gbc_finPanel.anchor = GridBagConstraints.EAST;
		gbc_finPanel.fill = GridBagConstraints.BOTH;
		gbc_finPanel.gridx = 0;
		gbc_finPanel.gridy = 3;
		add(finPanel, gbc_finPanel);
		
		JButton btnJugar = new JButton("Jugar");
		btnJugar.setFont(new Font("Dialog", Font.BOLD, 14));
		btnJugar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SuperPalitos.getInstance().play();
			}
		});
		
		JButton btnTerminar = new JButton("Terminar");
		btnTerminar.setFont(new Font("Dialog", Font.PLAIN, 12));
		btnTerminar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SuperPalitos.getInstance().terminar();
			}
		});
		finPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
		finPanel.add(btnTerminar);
		finPanel.add(btnJugar);
	}

	protected JLabel getMarcadorLabel() {
		return marcadorLabel;
	}
	protected JPanel getFinPanel() {
		return finPanel;
	}
	
  public void showFinPanel(boolean show) {
    finPanel.setVisible(show);
  	jLabel1.setVisible(show);
}

public void setMarcador(String msg) {
    marcadorLabel.setText(msg);
}

public void showFinPanel(String string, boolean b) {
	jLabel1.setText(string);
	showFinPanel(b);
}
	protected JLabel getJLabel1() {
		return jLabel1;
	}
}
